/**
 * StarInfoFramePlayerColony.java
 *
 * Roslan's Remake of MOO in 3D using Ardor3D
 * (C) 2011 Roslan Amir. All rights reserved.
 */

package com.roslan.games.moo3d.ui.hud;

import com.ardor3d.extension.ui.UIButton;
import com.ardor3d.extension.ui.UICheckBox;
import com.ardor3d.extension.ui.UILabel;
import com.ardor3d.extension.ui.UIPanel;
import com.ardor3d.extension.ui.event.ActionEvent;
import com.ardor3d.extension.ui.event.ActionListener;
import com.ardor3d.extension.ui.layout.AnchorLayout;
import com.ardor3d.extension.ui.layout.AnchorLayoutData;
import com.ardor3d.extension.ui.util.Alignment;
import com.roslan.games.moo3d.data.Colony;
import com.roslan.games.moo3d.spatial.StarNode;

/**
 * This Panel displays the information about the currently selected player Colony.
 * 
 * @author Roslan Amir
 * @version 1.0 - Jan 10, 2011
 */
public class StarInfoFrameColonyPlayer extends StarInfoFrameColonyBase {

	/**
	 * The label for the colony production value.
	 */
	protected final UILabel productionValueLabel;

	/**
	 * The label for the colony factories count.
	 */
	protected final UILabel factoriesValueLabel;

	/**
	 * The label for the colony waste count.
	 */
	protected final UILabel wasteValueLabel;

	/**
	 * The label for the colony spacedock value.
	 */
	protected final UILabel spacedockValueLabel;

	/**
	 * The current colony.
	 */
	private transient Colony colony;

	/**
	 * Labels that are updateable.
	 */
	private UILabel shipRatioLabel;
	private UILabel defenseRatioLabel;
	private UILabel industryRatioLabel;
	private UILabel ecologyRatioLabel;
	private UILabel researchRatioLabel;
	private UILabel shipStatusLabel;
	private UILabel defenseStatusLabel;
	private UILabel industryStatusLabel;
	private UILabel ecologyStatusLabel;
	private UILabel researchStatusLabel;

	/**
	 * Default no-arg constructor.
	 */
	public StarInfoFrameColonyPlayer() {
		super("StarInfoFramePlayerColony");

		/*
		 * The production and factories panel
		 */
		final UIPanel panel1 = new UIPanel();
		panel1.setLayout(new AnchorLayout());
		panel1.setMargin(HudManager.MARGINS_ZERO);
		panel1.setPadding(HudManager.PADDING_2000);
		panel1.setBorder(HudManager.SOLID_BORDER_TWO);
		infoPanel.add(panel1);

		/*
		 * Production
		 */
//		final UILabel productionNameLabel = new UILabel("[b]Production:[/b]");
		final UILabel productionNameLabel = new UILabel("Production:");
		productionNameLabel.setStyledText(true);
		productionNameLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel1, Alignment.TOP_LEFT, 4, -6));
		panel1.add(productionNameLabel);

		productionValueLabel = new UILabel("");
		productionValueLabel.setStyledText(true);
		productionValueLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel1, Alignment.TOP_LEFT, 90, -6)); // 105
		panel1.add(productionValueLabel);

		/*
		 * Factories
		 */
//		final UILabel factoriesNameLabel = new UILabel("[b]Factories:[/b]");
		final UILabel factoriesNameLabel = new UILabel("Factories:");
		factoriesNameLabel.setStyledText(true);
		factoriesNameLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel1, Alignment.TOP_LEFT, 202, -6));
		panel1.add(factoriesNameLabel);

		factoriesValueLabel = new UILabel("");
		factoriesValueLabel.setStyledText(true);
		factoriesValueLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel1, Alignment.TOP_LEFT, 278, -6)); // 279
		panel1.add(factoriesValueLabel);

		/*
		 * Waste
		 */
//		final UILabel wasteNameLabel = new UILabel("[b]Waste:[/b]");
		final UILabel wasteNameLabel = new UILabel("Waste:");
		wasteNameLabel.setStyledText(true);
		wasteNameLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel1, Alignment.TOP_LEFT, 326, -6));
		panel1.add(wasteNameLabel);

		wasteValueLabel = new UILabel("");
		wasteValueLabel.setStyledText(true);
		wasteValueLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel1, Alignment.TOP_LEFT, 380, -6)); // 400
		panel1.add(wasteValueLabel);

		/*
		 * The spending panel
		 */
		final UIPanel panel2 = new UIPanel();
		panel2.setLayout(new AnchorLayout());
		panel2.setMargin(HudManager.MARGINS_ZERO);
		panel2.setPadding(HudManager.PADDING_2000);
		panel2.setBorder(HudManager.SOLID_BORDER_TWO);
		infoPanel.add(panel2);

		/*
		 * The LOCK buttons for each spending area
		 */

		final UICheckBox shipLockButton = new UICheckBox();
		shipLockButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 4, -11));
		shipLockButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.lockedShip = shipLockButton.isSelected();
			}
		});
		panel2.add(shipLockButton);

		final UICheckBox defenseLockButton = new UICheckBox();
		defenseLockButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 4, -39));
		defenseLockButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.lockedDefense = defenseLockButton.isSelected();
			}
		});
		panel2.add(defenseLockButton);

		final UICheckBox industryLockButton = new UICheckBox();
		industryLockButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 4, -67));
		industryLockButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.lockedIndustry = industryLockButton.isSelected();
			}
		});
		panel2.add(industryLockButton);

		final UICheckBox ecologyLockButton = new UICheckBox();
		ecologyLockButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 4, -95));
		ecologyLockButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.lockedEcology = ecologyLockButton.isSelected();
			}
		});
		panel2.add(ecologyLockButton);

		final UICheckBox researchLockButton = new UICheckBox();
		researchLockButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 4, -123));
		researchLockButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.lockedResearch = researchLockButton.isSelected();
			}
		});
		panel2.add(researchLockButton);

		/*
		 * The spending area labels
		 */

//		final UILabel shipNameLabel = new UILabel("[b]Ship[/b]");
		final UILabel shipNameLabel = new UILabel("Ship");
		shipNameLabel.setStyledText(true);
		shipNameLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 26, -11));
		panel2.add(shipNameLabel);

//		final UILabel defenseNameLabel = new UILabel("[b]Defense[/b]");
		final UILabel defenseNameLabel = new UILabel("Defense");
		defenseNameLabel.setStyledText(true);
		defenseNameLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 26, -39));
		panel2.add(defenseNameLabel);

//		final UILabel industryNameLabel = new UILabel("[b]Industry[/b]");
		final UILabel industryNameLabel = new UILabel("Industry");
		industryNameLabel.setStyledText(true);
		industryNameLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 26, -67));
		panel2.add(industryNameLabel);

//		final UILabel ecologyNameLabel = new UILabel("[b]Ecology[/b]");
		final UILabel ecologyNameLabel = new UILabel("Ecology");
		ecologyNameLabel.setStyledText(true);
		ecologyNameLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 26, -95));
		panel2.add(ecologyNameLabel);

//		final UILabel researchNameLabel = new UILabel("[b]Research[/b]");
		final UILabel researchNameLabel = new UILabel("Research");
		researchNameLabel.setStyledText(true);
		researchNameLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 26, -123));
		panel2.add(researchNameLabel);

		/*
		 * The minimize buttons
		 */

		final UIButton shipMinButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[0]);
		shipMinButton.setStyledText(true);
		shipMinButton.setGap(0);
		shipMinButton.setMargin(HudManager.MARGINS_ZERO);
		shipMinButton.setPadding(HudManager.PADDING_ZERO);
		shipMinButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 100, -6));
		shipMinButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.minimizeShipRatio();
				updateSpendingText();
			}
		});
		panel2.add(shipMinButton);

		final UIButton defenseMinButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[0]);
		defenseMinButton.setStyledText(true);
		defenseMinButton.setGap(0);
		defenseMinButton.setMargin(HudManager.MARGINS_ZERO);
		defenseMinButton.setPadding(HudManager.PADDING_ZERO);
		defenseMinButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 100, -34));
		defenseMinButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.minimizeDefenseRatio();
				updateSpendingText();
			}
		});
		panel2.add(defenseMinButton);

		final UIButton industryMinButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[0]);
		industryMinButton.setStyledText(true);
		industryMinButton.setGap(0);
		industryMinButton.setMargin(HudManager.MARGINS_ZERO);
		industryMinButton.setPadding(HudManager.PADDING_ZERO);
		industryMinButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 100, -62));
		industryMinButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.minimizeIndustryRatio();
				updateSpendingText();
			}
		});
		panel2.add(industryMinButton);

		final UIButton ecologyMinButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[0]);
		ecologyMinButton.setStyledText(true);
		ecologyMinButton.setGap(0);
		ecologyMinButton.setMargin(HudManager.MARGINS_ZERO);
		ecologyMinButton.setPadding(HudManager.PADDING_ZERO);
		ecologyMinButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 100, -90));
		ecologyMinButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.minimizeEcologyRatio();
				updateSpendingText();
			}
		});
		panel2.add(ecologyMinButton);

		final UIButton researchMinButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[0]);
		researchMinButton.setStyledText(true);
		researchMinButton.setGap(0);
		researchMinButton.setMargin(HudManager.MARGINS_ZERO);
		researchMinButton.setPadding(HudManager.PADDING_ZERO);
		researchMinButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 100, -118));
		researchMinButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.minimizeResearchRatio();
				updateSpendingText();
			}
		});
		panel2.add(researchMinButton);

		/*
		 * The decrement buttons
		 */

		final UIButton shipMinusButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[1]);
		shipMinusButton.setStyledText(true);
		shipMinusButton.setGap(0);
		shipMinusButton.setMargin(HudManager.MARGINS_ZERO);
		shipMinusButton.setPadding(HudManager.PADDING_ZERO);
		shipMinusButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 141, -6));
		shipMinusButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.decreaseShipRatio();
				updateSpendingText();
			}
		});
		panel2.add(shipMinusButton);

		final UIButton defenseMinusButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[1]);
		defenseMinusButton.setStyledText(true);
		defenseMinusButton.setGap(0);
		defenseMinusButton.setMargin(HudManager.MARGINS_ZERO);
		defenseMinusButton.setPadding(HudManager.PADDING_ZERO);
		defenseMinusButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 141, -34));
		defenseMinusButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.decreaseDefenseRatio();
				updateSpendingText();
			}
		});
		panel2.add(defenseMinusButton);

		final UIButton industryMinusButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[1]);
		industryMinusButton.setStyledText(true);
		industryMinusButton.setGap(0);
		industryMinusButton.setMargin(HudManager.MARGINS_ZERO);
		industryMinusButton.setPadding(HudManager.PADDING_ZERO);
		industryMinusButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 141, -62));
		industryMinusButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.decreaseIndustryRatio();
				updateSpendingText();
			}
		});
		panel2.add(industryMinusButton);

		final UIButton ecologyMinusButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[1]);
		ecologyMinusButton.setStyledText(true);
		ecologyMinusButton.setGap(0);
		ecologyMinusButton.setMargin(HudManager.MARGINS_ZERO);
		ecologyMinusButton.setPadding(HudManager.PADDING_ZERO);
		ecologyMinusButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 141, -90));
		ecologyMinusButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.decreaseEcologyRatio();
				updateSpendingText();
			}
		});
		panel2.add(ecologyMinusButton);

		final UIButton researchMinusButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[1]);
		researchMinusButton.setStyledText(true);
		researchMinusButton.setGap(0);
		researchMinusButton.setMargin(HudManager.MARGINS_ZERO);
		researchMinusButton.setPadding(HudManager.PADDING_ZERO);
		researchMinusButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 141, -118));
		researchMinusButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.decreaseResearchRatio();
				updateSpendingText();
			}
		});
		panel2.add(researchMinusButton);

		/*
		 * The spending ratios
		 */

//		shipRatioLabel = new UILabel("[b]100%[/b]");
		shipRatioLabel = new UILabel("100%");
		shipRatioLabel.setStyledText(true);
		shipRatioLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 173, -11));
		panel2.add(shipRatioLabel);

//		defenseRatioLabel = new UILabel("[b]100%[/b]");
		defenseRatioLabel = new UILabel("100%");
		defenseRatioLabel.setStyledText(true);
		defenseRatioLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 173, -39));
		panel2.add(defenseRatioLabel);

//		industryRatioLabel = new UILabel("[b]100%[/b]");
		industryRatioLabel = new UILabel("100%");
		industryRatioLabel.setStyledText(true);
		industryRatioLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 173, -67));
		panel2.add(industryRatioLabel);

//		ecologyRatioLabel = new UILabel("[b]100%[/b]");
		ecologyRatioLabel = new UILabel("100%");
		ecologyRatioLabel.setStyledText(true);
		ecologyRatioLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 173, -95));
		panel2.add(ecologyRatioLabel);

//		researchRatioLabel = new UILabel("[b]100%[/b]");
		researchRatioLabel = new UILabel("100%");
		researchRatioLabel.setStyledText(true);
		researchRatioLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 173, -123));
		panel2.add(researchRatioLabel);

		/*
		 * The increment buttons
		 */

		final UIButton shipPlusButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[2]);
		shipPlusButton.setStyledText(true);
		shipPlusButton.setGap(0);
		shipPlusButton.setMargin(HudManager.MARGINS_ZERO);
		shipPlusButton.setPadding(HudManager.PADDING_ZERO);
		shipPlusButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 215, -6));
		shipPlusButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.increaseShipRatio();
				updateSpendingText();
			}
		});
		panel2.add(shipPlusButton);

		final UIButton defensePlusButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[2]);
		defensePlusButton.setStyledText(true);
		defensePlusButton.setGap(0);
		defensePlusButton.setMargin(HudManager.MARGINS_ZERO);
		defensePlusButton.setPadding(HudManager.PADDING_ZERO);
		defensePlusButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 215, -34));
		defensePlusButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.increaseDefenseRatio();
				updateSpendingText();
			}
		});
		panel2.add(defensePlusButton);

		final UIButton industryPlusButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[2]);
		industryPlusButton.setStyledText(true);
		industryPlusButton.setGap(0);
		industryPlusButton.setMargin(HudManager.MARGINS_ZERO);
		industryPlusButton.setPadding(HudManager.PADDING_ZERO);
		industryPlusButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 215, -62));
		industryPlusButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.increaseIndustryRatio();
				updateSpendingText();
			}
		});
		panel2.add(industryPlusButton);

		final UIButton ecologyPlusButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[2]);
		ecologyPlusButton.setStyledText(true);
		ecologyPlusButton.setGap(0);
		ecologyPlusButton.setMargin(HudManager.MARGINS_ZERO);
		ecologyPlusButton.setPadding(HudManager.PADDING_ZERO);
		ecologyPlusButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 215, -90));
		ecologyPlusButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.increaseEcologyRatio();
				updateSpendingText();
			}
		});
		panel2.add(ecologyPlusButton);

		final UIButton researchPlusButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[2]);
		researchPlusButton.setStyledText(true);
		researchPlusButton.setGap(0);
		researchPlusButton.setMargin(HudManager.MARGINS_ZERO);
		researchPlusButton.setPadding(HudManager.PADDING_ZERO);
		researchPlusButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 215, -118));
		researchPlusButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.increaseResearchRatio();
				updateSpendingText();
			}
		});
		panel2.add(researchPlusButton);

		/*
		 * The maximize buttons
		 */

		final UIButton shipMaxButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[3]);
		shipMaxButton.setStyledText(true);
		shipMaxButton.setGap(0);
		shipMaxButton.setMargin(HudManager.MARGINS_ZERO);
		shipMaxButton.setPadding(HudManager.PADDING_ZERO);
		shipMaxButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 247, -6));
		shipMaxButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.maximizeShipRatio();
				updateSpendingText();
			}
		});
		panel2.add(shipMaxButton);

		final UIButton defenseMaxButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[3]);
		defenseMaxButton.setStyledText(true);
		defenseMaxButton.setGap(0);
		defenseMaxButton.setMargin(HudManager.MARGINS_ZERO);
		defenseMaxButton.setPadding(HudManager.PADDING_ZERO);
		defenseMaxButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 247, -34));
		defenseMaxButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.maximizeDefenseRatio();
				updateSpendingText();
			}
		});
		panel2.add(defenseMaxButton);

		final UIButton industryMaxButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[3]);
		industryMaxButton.setStyledText(true);
		industryMaxButton.setGap(0);
		industryMaxButton.setMargin(HudManager.MARGINS_ZERO);
		industryMaxButton.setPadding(HudManager.PADDING_ZERO);
		industryMaxButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 247, -62));
		industryMaxButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.maximizeIndustryRatio();
				updateSpendingText();
			}
		});
		panel2.add(industryMaxButton);

		final UIButton ecologyMaxButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[3]);
		ecologyMaxButton.setStyledText(true);
		ecologyMaxButton.setGap(0);
		ecologyMaxButton.setMargin(HudManager.MARGINS_ZERO);
		ecologyMaxButton.setPadding(HudManager.PADDING_ZERO);
		ecologyMaxButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 247, -90));
		ecologyMaxButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.maximizeEcologyRatio();
				updateSpendingText();
			}
		});
		panel2.add(ecologyMaxButton);

		final UIButton researchMaxButton = new UIButton("", SUBTEX_ALLOC_BUTTONS[3]);
		researchMaxButton.setStyledText(true);
		researchMaxButton.setGap(0);
		researchMaxButton.setMargin(HudManager.MARGINS_ZERO);
		researchMaxButton.setPadding(HudManager.PADDING_ZERO);
		researchMaxButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 247, -118));
		researchMaxButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.maximizeResearchRatio();
				updateSpendingText();
			}
		});
		panel2.add(researchMaxButton);

		/*
		 * Defense allocation and status
		 */
//		shipStatusLabel = new UILabel("[b]3 turns[/b]");
		shipStatusLabel = new UILabel("");
		shipStatusLabel.setStyledText(true);
		shipStatusLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 288, -11));
		panel2.add(shipStatusLabel);

		/*
		 * Defense allocation and status
		 */
//		defenseStatusLabel = new UILabel("[b]3 turns[/b]");
		defenseStatusLabel = new UILabel("");
		defenseStatusLabel.setStyledText(true);
		defenseStatusLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 288, -39));
		panel2.add(defenseStatusLabel);

		/*
		 * Industry allocation and status
		 */
//		industryStatusLabel = new UILabel("[b]3 turns[/b]");
		industryStatusLabel = new UILabel("");
		industryStatusLabel.setStyledText(true);
		industryStatusLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 288, -67));
		panel2.add(industryStatusLabel);

		/*
		 * Ecology allocation and status
		 */
//		ecologyStatusLabel = new UILabel("[b]3 turns[/b]");
		ecologyStatusLabel = new UILabel("");
		ecologyStatusLabel.setStyledText(true);
		ecologyStatusLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 288, -95));
		panel2.add(ecologyStatusLabel);

		/*
		 * Research allocation and status
		 */
//		researchStatusLabel = new UILabel("[b]3 turns[/b]");
		researchStatusLabel = new UILabel("");
		researchStatusLabel.setStyledText(true);
		researchStatusLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel2, Alignment.TOP_LEFT, 288, -123));
		panel2.add(researchStatusLabel);

		/*
		 * The spacedock panel
		 */
		final UIPanel panel3 = new UIPanel();
		panel3.setLayout(new AnchorLayout());
		panel3.setMargin(HudManager.MARGINS_ZERO);
		panel3.setPadding(HudManager.PADDING_2000);
		panel3.setBorder(HudManager.SOLID_BORDER_TWO);
		infoPanel.add(panel3);

		/*
		 * Spacedock
		 */
//		final UILabel spacedockNameLabel = new UILabel("[b]Spacedock:[/b]");
		final UILabel spacedockNameLabel = new UILabel("Spacedock:");
		spacedockNameLabel.setStyledText(true);
		spacedockNameLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel3, Alignment.TOP_LEFT, 4, -10));
		panel3.add(spacedockNameLabel);

		spacedockValueLabel = new UILabel("");
		spacedockValueLabel.setStyledText(true);
		spacedockValueLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel3, Alignment.TOP_LEFT, 105, -10));
		panel3.add(spacedockValueLabel);

//		final UIButton changeButton = new UIButton("[b]Change[/b]");
		final UIButton changeButton = new UIButton("Change");
		changeButton.setStyledText(true);
		changeButton.setGap(0);
		changeButton.setMargin(HudManager.MARGINS_ZERO);
		changeButton.setPadding(HudManager.PADDING_ZERO);
		changeButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel3, Alignment.TOP_LEFT, 326, -6));
		changeButton.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent event) {
				colony.changeSpacedockShip();
				updateSpacedockText();
				shipStatusLabel.setText(colony.shipStatusText);
			}
		});
		panel3.add(changeButton);
	}

	/**
	 * Update the information to the currently selected Star (or Colony).
	 * 
	 * @param starNode - the Star (or Colony) whose info is to be updated
	 */
	@Override
	public void update(StarNode starNode) {
		super.update(starNode);

		colony = (Colony) starNode.getStar();
//		productionValueLabel.setText("[b][c=#00a]" + colony.netProduction + '(' + colony.baseProduction + ')' + "[/c][/b]");
//		factoriesValueLabel.setText("[b][c=#00a]" + colony.factories + "[/c][/b]");
//		wasteValueLabel.setText("[b][c=#00a]" + colony.waste + "[/c][/b]");
		productionValueLabel.setText("[c=#00a]" + colony.netProduction + '(' + colony.baseProduction + ')' + "[/c]");
		factoriesValueLabel.setText("[c=#00a]" + colony.factories + "[/c]");
		wasteValueLabel.setText("[c=#00a]" + colony.waste + "[/c]");
		updateSpendingText();
		updateSpacedockText();

//		this.backDrop.setColor(GameData.RACE_COLORS[colony.owner.bannerIndex]);
		this.setTitle(starNode.getName() + " (" + starNode.tile.x + ',' + starNode.tile.y + ") (" + colony.owner.getRaceNamePlural() + ')');

		updateAndpack();
	}

	/**
	 * Update the spending labels.
	 */
	private void updateSpendingText() {
		shipRatioLabel.setText(colony.shipRatioText);
		defenseRatioLabel.setText(colony.defenseRatioText);
		industryRatioLabel.setText(colony.industryRatioText);
		ecologyRatioLabel.setText(colony.ecologyRatioText);
		researchRatioLabel.setText(colony.researchRatioText);
		shipStatusLabel.setText(colony.shipStatusText);
		defenseStatusLabel.setText(colony.defenseStatusText);
		industryStatusLabel.setText(colony.industryStatusText);
		ecologyStatusLabel.setText(colony.ecologyStatusText);
		researchStatusLabel.setText(colony.researchStatusText);
	}

	/**
	 * Update the spacedock label.
	 */
	private void updateSpacedockText() {
//		spacedockValueLabel.setText("[b][c=#00a]" + colony.getShipTypeName() + "[/c][/b]");
		spacedockValueLabel.setText("[c=#00a]" + colony.getShipTypeName() + "[/c]");
	}

}
